package main

import (
	"fmt"
	"strconv"
)

/*
	基本数据类型转string
		1. fmt.Sprintf(格式，变量)
		2. strconv.FormatInt Float Bool

*/
func main() {
	// fmt.Sprintf
	var n1 int = 10
	var n2 float32 = 122.99
	var n3 bool = true
	var str string
	fmt.Printf("%T", n1)

	str = fmt.Sprintf("%d", n1)
	fmt.Println(str)

	str = fmt.Sprintf("%f", n2)
	fmt.Println(str)

	str = fmt.Sprintf("%t", n3)
	fmt.Println(str)

	// strconv
	str = strconv.FormatInt(int64(n1), 10)
	fmt.Println(str)

	str = strconv.FormatFloat(float64(n2), 'f', 10, 32)
	fmt.Println(str)

	str = strconv.FormatBool(n3)
	fmt.Println(str)

	str = strconv.Itoa(n1)
	fmt.Println(str)
}
